package com.bringway.global.quartz;
import java.util.Calendar;
import java.util.Date;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.bringway.framework.util.DateUtils;
import com.bringway.p2p.dao.TjbbDao;
public class DayBBTaskJob {
	
	private static Logger logger = Logger.getLogger(DayBBTaskJob.class);

	public DayBBTaskJob() {
		System.err.println("DayBBTaskJob 初始化...");
	}
	
	@Autowired
	private TjbbDao tjbbDao;

	public void run(){
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		calendar.add(Calendar.DAY_OF_MONTH, -1);  //设置为前一天
		Date Before = calendar.getTime();   //得到前一天的时间
		String tjDate = DateUtils.format(Before);
		try{
			logger.info("DayBBTaskJob 日报表自动计算 tjDate ： " + tjDate + ",start....");
			tjbbDao.insertCacheTable(tjDate);
			logger.info("DayBBTaskJob 日报表自动计算 tjDate ： " + tjDate + ",end....");
		}catch(Exception e){
			tjbbDao.deleteCache(tjDate);
			logger.info("DayBBTaskJob 日报表自动计算 tjDate ： " + tjDate + ",失败....");
			e.printStackTrace();
		}
	}
}
